#ifndef STX_ALGORITHM_FIND_IF_HPP
#define STX_ALGORITHM_FIND_IF_HPP

#include <stx/algorithm/common.hpp>

namespace stx {

template <class InputIterator, class Predicate>
inline InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred)
{
    for (; first != last; ++first) {
        if (pred(*first)) {
            break;
        }
    }
    return first;
}

template<class Container, class Predicate>
inline typename Container::iterator
find_if(Container& c, Predicate pred)
{
    return stx::find_if(stx::begin(c), stx::end(c), pred);
}

template<class Container, class Predicate>
inline typename Container::const_iterator
find_if(const Container& c, Predicate pred)
{
    return stx::find_if(stx::begin(c), stx::end(c), pred);
}

template<class InputIterator, class Predicate>
inline InputIterator
find_if(stx::iterator_range<InputIterator> r, Predicate pred)
{
    return stx::find_if(stx::begin(r), stx::end(r), pred);
}

} // namespace stx

#endif // STX_ALGORITHM_FIND_IF_HPP
